package operation;

import book.BookList;

import java.util.Scanner;

public class Return implements IOPeration{
    @Override
    public void work(BookList bookList) {
        Scanner sc = new Scanner(System.in);
        System.out.print("请输入要借归还书的名字:");
        String name = sc.nextLine();
        for (int i = 0; i < bookList.getBookNum(); i++) {
            if(name.equals(bookList.getBooklist()[i].getName())) {
                if(bookList.getBooklist()[i].isLend() == false) {
                    System.out.print("该书还未借出->");
                    System.out.println(bookList.getBooklist()[i]);
                    return;
                }
                System.out.print("归还成功->");
                System.out.println(bookList.getBooklist()[i]);
                bookList.getBooklist()[i].setLend(false);
                return;
            }
        }
        System.out.println("没有找到该名字的书！！！");
    }
}

